<?php
/**
 *   Joomdiet - components/views/recipeinfotable/view.raw.php
 *   Author: Juan Dapena Paz (juan@bittingbits.com)
 *   Copyright (C) 2010 Bitting Bits S.L.
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.view');

class JoomdietViewRecipeInfoTable extends JView
{
    function display($tpl=null)
    {
        $textid = JRequest::getVar('cid');
        $recipe_model = $this->getModel();
        $recipe_category_model = $this->getModel('RecipeCategory');
        $recipe_food_model = $this->getModel('RecipeFood');
        $variable_model = $this->getModel('Variable');
        $food_model = $this->getModel('Food');
        $food_variable_model = $this->getModel('FoodVariable');
        
        $result = $recipe_model->getRecipe(substr($textid, 7));
        $category = $recipe_category_model->getCategory($result->recipe_category_id);
        $recipefood = $recipe_food_model->getData($result->id);
        $customizedamount = JRequest::getVar('amountfield');
        if (!$customizedamount) {
            $customizedamount = JRequest::getVar('amountvalue');
            if (!$customizedamount) {
                $customizedamount = 1;
            }
        } else {
            $customizedamount = $customizedamount;
        }
        
        $this->assignRef('recipe', $result);
        $this->assignRef('category', $category);
        $this->assignRef('recipefood', $recipefood);
        $this->assignRef('variable_model', $variable_model);
        $this->assignRef('food_model', $food_model);
        $this->assignRef('customizedamount', $customizedamount);
        $this->assignRef('foodvariable_model', $food_variable_model);
        
        parent::display($tpl);
    }
}
?>
